/*
 * Created on 2005-1-24
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package  org.fantasy.common.exception;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 *  数据库操作异常
 * @author: 王文成
 * @version: 1.0
 * @since 2009-3-4
 */
public class DBException extends Exception {
    private static Log log = LogFactory.getLog(DBException.class);

    private String sql;

    public DBException() {
        super();
    }

    public DBException(Exception e) {
        super(e);
    }

    public DBException(String message) {
        super(message);
    }

    public DBException(String message, String sql) {
        super(message);
        this.sql = sql;
    }

    @Override
    public String toString() {
        if (sql == null)
            return super.toString();
        else
            return super.toString() + " \n" + sql.toString() + " \n";
    }

    @Override
    public void printStackTrace() {
        super.printStackTrace();
        log.error(sql);
    }
}
